Skip to content

refactor: overhaul review queue and PR fixer with structured output - #65

Merged
Gkrumbach07 merged 1 commit into
mainfrom
worktree-review-queue
Mar 11, 2026
Merged

Gkrumbach07 merged 1 commit into
mainfrom
worktree-review-queue

Conversation

@Gkrumbach07

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #63. Overhauls both workflows based on real-world usage feedback.

Structured output per PR

Each PR now gets a clean directory layout that the agent reads hierarchically:

  • summary.json — one read tells the agent what's wrong and where to dig deeper
  • comments/ — overview + chronological numbered files (with IDs for replying)
  • ci/ — overview + failure logs (opt-in, truncated to 200 lines)
  • diff.json — single file with overview + patches
  • reviews/ — approval state overview
  • analysis.json — written separately by analyze script (never modifies summary)

Simplified CLAUDE.md files (71% reduction)

  • PR Fixer: 254 → 86 lines
  • Review Queue: 391 → 102 lines
  • Removed prescriptive bash snippets the agent already knows
  • What remains: goal, scripts, judgment calls, constraints

PR Fixer improvements

  • Replies on inline comment threads when fixing issues (not just silent code changes)
  • Reads actual CI failure logs instead of guessing at fixes
  • Extracts structured "Prompt for AI Agents" blocks from bot reviews (CodeRabbit etc.)

Script changes

  • structure-pr-data.py — new shared data processor (duplicated in each workflow)
  • fetch-pr.sh — parallel API calls, --with-logs for CI failure output
  • fetch-prs.sh — loops all PRs, uses same data processor
  • analyze-prs.py — reads new structure, writes analysis.json + queue.json
  • Deleted: merge-comments.py, test-merge-order.sh

Test plan

  • Run fetch-pr.sh against a single PR, verify directory layout
  • Run fetch-prs.sh against repo with open PRs
  • Run analyze-prs.py on fetched data, verify queue.json
  • Verify --with-logs fetches truncated CI failure logs
  • Run PR fixer via @ambient-fix and verify it reads structured data

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 62180e39-98d8-4f4f-a9c3-cc2e40ee7563

📥 Commits

Reviewing files that changed from the base of the PR and between be9380e and 5e533d2.

📒 Files selected for processing (9)
  • internal-workflows/pr-fixer/CLAUDE.md
  • internal-workflows/pr-fixer/scripts/fetch-pr.sh
  • internal-workflows/pr-fixer/scripts/merge-comments.py
  • internal-workflows/pr-fixer/scripts/structure-pr-data.py
  • internal-workflows/pr-overview/CLAUDE.md
  • internal-workflows/pr-overview/scripts/analyze-prs.py
  • internal-workflows/pr-overview/scripts/fetch-prs.sh
  • internal-workflows/pr-overview/scripts/structure-pr-data.py
  • internal-workflows/pr-overview/scripts/test-merge-order.sh

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting


Walkthrough

This PR refactors internal PR workflow scripts and documentation across two pipelines (pr-fixer and pr-overview). Changes introduce dedicated Python data-structuring scripts to consolidate artifact organization, remove deprecated utilities, simplify shell script argument handling, and replace verbose multi-phase guidance with modular, action-first workflows.

Changes

Cohort / File(s) Summary
PR Fixer Documentation
internal-workflows/pr-fixer/CLAUDE.md
Simplified agent instructions from verbose multi-phase task checklist to concise action-first workflow with streamlined Phase structure, updated fetch script usage (new --with-logs flag), restructured artifact output (artifacts/{number}/ layout), and consolidated PR fix report format.
PR Fixer Fetch Script
internal-workflows/pr-fixer/scripts/fetch-pr.sh
Refactored argument parsing, introduced persistent temporary directory (TMPDIR) for parallel data fetches with consolidated error handling, added optional CI failure log collection via --with-logs, replaced multi-phase post-processing with single structure-pr-data.py invocation, and adjusted default output path from artifacts/pr-fixer/${PR_NUM} to artifacts/${PR_NUM}.
PR Fixer Data Structuring
internal-workflows/pr-fixer/scripts/structure-pr-data.py
New Python script that reorganizes raw PR API data into structured artifacts directory, including summary.json, comments/ (overview + per-comment files), ci/ (overview + logs), diff.json, and reviews/overview.json, with helper functions for building comments, CI status categorization, and review aggregation.
PR Overview Documentation
internal-workflows/pr-overview/CLAUDE.md
Reworked from monolithic step-by-step workflow into modular script-driven pipeline with labeled phases (Fetch, Analyze, Sub-Agent Evaluation, Ranking, etc.), introduced concrete per-PR artifacts layout, replaced detailed blocker tables with unified 4-column Blocker Checklist, and simplified verdict schema.
PR Overview Fetch Script
internal-workflows/pr-overview/scripts/fetch-prs.sh
Replaced scattered argument parsing with concise inline cases, introduced per-PR directory approach with dedicated PR_TMP directories, integrated structure-pr-data.py invocation for each PR, adjusted diff fetch logic to operate per-PR, and streamlined progress messages.
PR Overview Analysis Script
internal-workflows/pr-overview/scripts/analyze-prs.py
Major refactoring to operate on structured per-PR summary.json instead of index-based inputs; replaced complex classification logic with summary-centric classify_type(); simplified blocker checks (check_ci, check_conflicts, check_reviews, check_jira, check_staleness); removed diff-hunk overlap analysis; generates per-PR analysis.json and new queue.json with aggregated review order and stats.
PR Overview Data Structuring
internal-workflows/pr-overview/scripts/structure-pr-data.py
New Python script (identical architecture to pr-fixer version) that transforms GitHub PR API data into consolidated artifact structure with summary.json, comments/, ci/, diff.json, and reviews/ subdirectories, providing standardized data format for downstream analysis.
Removed Utilities
internal-workflows/pr-fixer/scripts/merge-comments.py, internal-workflows/pr-overview/scripts/test-merge-order.sh
Deleted merge-comments.py (comment aggregation logic now in structure-pr-data.py) and test-merge-order.sh (local merge testing utility no longer needed in refactored pipeline).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FetchScript as fetch-pr.sh / fetch-prs.sh
    participant TMPDIR
    participant StructureScript as structure-pr-data.py
    participant OutputDir as artifacts/{number}/
    participant AnalyzeScript as analyze-prs.py

    User->>FetchScript: Invoke with --repo, --pr/--output-dir
    FetchScript->>TMPDIR: Create temp directory
    FetchScript->>TMPDIR: Fetch pr.json, reviews.json, review_comments.json in parallel
    FetchScript->>TMPDIR: Optionally fetch check_runs.json and CI logs
    FetchScript->>StructureScript: Pass TMPDIR artifacts
    StructureScript->>OutputDir: Generate summary.json, comments/, ci/, diff.json, reviews/
    FetchScript->>User: Return output directory path
    
    Note over AnalyzeScript: (PR Overview only)
    User->>AnalyzeScript: Invoke with --output-dir
    AnalyzeScript->>OutputDir: Read per-PR summary.json files
    AnalyzeScript->>OutputDir: Write per-PR analysis.json
    AnalyzeScript->>OutputDir: Generate queue.json with rankings
    AnalyzeScript->>User: Return review order and stats
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch worktree-review-queue

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

New per-PR output structure:
  summary.json — one-read overview (metadata, CI, comments, reviews)
  comments/ — overview.json + chronological numbered files with IDs
  ci/ — overview.json + logs/ (opt-in via --with-logs, truncated 200 lines)
  diff.json — single file with overview + patches
  reviews/ — overview.json with approval state
  analysis.json — written separately by analyze-prs.py

Scripts:
- structure-pr-data.py: takes raw API JSON, produces clean directory
  (duplicated in each workflow since they run in isolation)
- fetch-pr.sh: parallel API calls, --with-logs for CI failure output
- fetch-prs.sh: loops all PRs, uses local structure-pr-data.py
- analyze-prs.py: reads summary.json, writes analysis.json + queue.json

CLAUDE.md files simplified: goal, scripts, judgment calls, constraints.

Deleted: merge-comments.py, test-merge-order.sh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Gkrumbach07
Gkrumbach07 force-pushed the worktree-review-queue branch from f426d2e to 5e533d2 Compare March 11, 2026 17:18
@Gkrumbach07
Gkrumbach07 marked this pull request as ready for review March 11, 2026 17:19
@Gkrumbach07
Gkrumbach07 merged commit 692d874 into main Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant